package rpc

import (
	"fmt"
	"os"
)

type Args struct {
	A, B int
}

type Result struct {
	Sum, Sub int
}

type Empty struct {
}

type CalcService struct {
}

type HelloService struct {
}

func (*CalcService) Sum(args *Args, sum *int) error {
	*sum = args.A + args.B
	return nil
}

func (*CalcService) Calc(args *Args, r *Result) error {
	r.Sum = args.A + args.B
	r.Sub = args.A - args.B
	return nil
}

func (*HelloService) Hello(args *Empty, r *Empty) error {
	fmt.Println("hello world")
	return nil
}

func checkError(err error) {
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
